<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<base href="<%=basePath%>">
	<meta charset="utf-8" />
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link href="static/css/bootstrap.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="static/css/ace.min.css" />
	<link rel="stylesheet" href="static/css/ace-skins.min.css" />
	<link rel="stylesheet" href="static/assets/css/font-awesome.css" />
	<!-- ace styles -->
	<link rel="stylesheet" href="static/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />
	<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
	<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>

	<script type="text/javascript">

		if("${msg}"=="success")
		{
			<%--alert("${msg}");--%>
			$(function(){
				$("#zhongxin").hide();
				$("#zhongxin3").show();
//				$("#zhongxin3").append("<input type='text'>aaaa");
			});
		}


		//继续导入
		function go_on(){
			window.location.href='<%=basePath%>student/goUploadExcel.do';
			
			}

		//保存
		function save(){
			if($("#DEPARTMENT_ID").val()==""||$("#DEPARTMENT_ID").val()==null){

				$("#DEPARTMENT_ID").tips({
					side:3,
					msg:'请选择院系',
					bg:'#AE81FF',
					time:3
				});
				return false;
			}



			if(($("#PROFESSION_ID").val()=="")||($("#PROFESSION_ID").val()==null)){

				$("#PROFESSION_ID").tips({
					side:3,
					msg:'请选择专业',
					bg:'#AE81FF',
					time:3
				});
				return false;
			}
			if($("#CLASSES_ID").val()==""||$("#CLASSES_ID").val()==null){

				$("#CLASSES_ID").tips({
					side:3,
					msg:'请选择班级',
					bg:'#AE81FF',
					time:3
				});
				return false;
			}

		/*	var radio=document.getElementsByName("OVERLAP");
			var flag=0;
			for(var i=0;i<radio.length;i++){
				if(radio[i].checked==true){
					flag=1;
					break;
				}
			}
			if(flag==0) {
				$("#OVERLAP").tips({
					side:3,
					msg:'请选择是否覆盖',
					bg:'#AE81FF',
					time:3
				});
				return false;
			}*/


			if($("#excel").val()=="" || document.getElementById("excel").files[0] =='请选择xls格式的文件'){

				$("#excel").tips({
					side:3,
					msg:'请选择文件',
					bg:'#AE81FF',
					time:3
				});
				return false;
			}


			$("#zhongxin").hide();
			$("#zhongxin2").show();
			$("#Form").submit();

		}

		function fileType(obj){
			var fileType=obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();//获得文件后缀名
			if(fileType != '.xls'){
				$("#excel").tips({
					side:3,
					msg:'请上传xls格式的文件',
					bg:'#AE81FF',
					time:3
				});
				$("#excel").val('');
				document.getElementById("excel").files[0] = '请选择xls格式的文件';
			}
		}
	</script>


	<script type="text/javascript">
		$(function () {
			$("#DEPARTMENT_ID").change(function () {

				var DEPARTMENT_ID = $("#DEPARTMENT_ID").val();

				$.ajax({
					type: "POST",//提交方式
					url: '<%=basePath%>student/getNext.do',//获取数据的函数
					data: {P_BM:DEPARTMENT_ID,tm:new Date().getTime()},//查询条件
					error: function () {
						alert("服务器异常")
					},//查询失败
					success: function (data) {//查询成功,data为返回的数据


							$("#PROFESSION_ID").empty();//先清除数据
							$("#CLASSES_ID").empty();//先清除数据

						if(data.tasks[0].BIANMA!=null)
							$.each(data.tasks, function (index, item) {
								$("#PROFESSION_ID").append("<option value=" + item.BIANMA + ">" + item.NAME + "</option>");//赋值
							});
						else
							$("#PROFESSION_ID").append("<option value=''>请选择专业</option>");

						var PROFESSION_ID = $("#PROFESSION_ID").val();
						$.ajax({
							type: "POST",//提交方式
							url: '<%=basePath%>student/getNext.do',//获取数据的函数
							data: {P_BM:PROFESSION_ID,tm:new Date().getTime()},//查询条件
							error: function () {
								alert("服务器异常")
							},//查询失败
							success: function (data) {//查询成功,data为返回的数据
								$("#CLASSES_ID").empty();//先清除数据

								if(data.tasks[0].BIANMA!=null)
								$.each(data.tasks, function (index, item) {
									$("#CLASSES_ID").append("<option value=" + item.BIANMA + ">" + item.NAME + "</option>");//赋值
								});
								else
									$("#CLASSES_ID").append("<option value=''>请选择班级</option>");

							}
						});
					}
				});
			});
		});

		$(function () {
			$("#PROFESSION_ID").change(function () {
				var PROFESSION_ID = $("#PROFESSION_ID").val();
				$.ajax({
					type: "POST",//提交方式
					url: '<%=basePath%>student/getNext.do',//获取数据的函数
					data: {P_BM:PROFESSION_ID,tm:new Date().getTime()},//查询条件
					error: function () {
						alert("服务器异常")
					},//查询失败
					success: function (data) {//查询成功,data为返回的数据
						$("#CLASSES_ID").empty();//先清除数据

						$.each(data.tasks, function (index, item) {
							$("#CLASSES_ID").append("<option value=" + item.BIANMA + ">" + item.NAME + "</option>");//赋值
						});
					}
				});
			});
		});



	</script>

</head>
<body>
<form action="student/readExcel.do" name="Form" id="Form" method="post" enctype="multipart/form-data">				<!--  readExcel -->
	<input id="msg" name="msg" type="hidden" value="${msg}">
	
	
	<div id="zhongxin" style="padding-top: 10px;margin:0px auto;">
	<div class="center" ><h4 class="lighter block green">学生信息批量导入</h4></div>
		<table style="width:95%;">
			<tr>
				<td align="center">导入到：</td>

				<td>
					<select <%--class="chzn-select"--%> style="width:140px" name="DEPARTMENT_ID" id="DEPARTMENT_ID" value="${pd.DEPARTMENT_ID}" data-placeholder="院系...">
						<option value="">请选择院系</option>
						<c:forEach items="${roleList1}" var="role">
							<option value="${role.BIANMA }" <%--<c:if test="${role.BIANMA == pd.DEPARTMENT_ID }">selected</c:if>--%>>${role.NAME }</option>
						</c:forEach>
					</select>
				</td>
				<td>
					<select <%--class="chzn-select"--%> style="width:140px" name="PROFESSION_ID" id="PROFESSION_ID" value="${pd.PROFESSION_ID}" data-placeholder="专业...">
						<option value="">请选择专业</option>
					</select>
				</td>
				<td >
					<select <%--class="chzn-select"--%> style="width:140px" name="CLASSES_ID" id="CLASSES_ID" value="${pd.CLASSES_ID}" data-placeholder="班级...">
						<option value="">请选择班级</option>
					</select>
				</td>
			</tr>
			<tr>
				<td style="width:300px" colspan="3"><input type="file" id="excel" name="excel" style="width:50px;"
														   onchange="fileType(this)"/></td>
			</tr>
			<tr>
				<td style="width:300px" colspan="3" align="center">
					<input name="OVERLAP" id="OVERLAP" type="radio" checked="checked" value="true" /><span class="lbl">覆盖重复数据</span>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input name="OVERLAP" id="OVERLAP1" type="radio" value="false" /><span class="lbl">不覆盖重复数据</span>
				</td>
			</tr>
			<tr>			 
				<td style="text-align: center" colspan="3">
					<a class="btn btn-mini btn-primary" onclick="save();">导入</a>
					<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
					<a class="btn btn-mini btn-success"
					   onclick="window.location.href='<%=basePath%>/student/downExcel.do'">下载模版</a>
				</td>
			</tr>





		</table>
	</div>

	<div id="zhongxin2" class="center" style="display:none"><br/><img src="static/images/jzx.gif" /><br/><h4 class="lighter block green"></h4></div>
	<div id="zhongxin3" class="center" style="display:none">
	<br> 
	<font size="6px">导入成功<font color="red">${successCount}</font>条，失败或重复不可写<font color="red">${failCount}</font>条</font></tr>
	<br>
	<br>
	<br>
    <a class="btn btn-mini btn-primary" onclick="go_on();">继续导入</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
	<tr>


	</tr>

	</div>

</form>


<!-- 引入 -->
<!--[if !IE]> -->
<script type="text/javascript">
	window.jQuery || document.write("<script src='static/assets/js/jquery.js'>"+"<"+"/script>");
</script>
<!-- <![endif]-->
<!--[if IE]>
<script type="text/javascript">
	window.jQuery || document.write("<script src='static/assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script src="static/js/bootstrap.min.js"></script>
<!-- ace scripts -->
<script src="static/assets/js/ace/elements.fileinput.js"></script>
<script src="static/assets/js/ace/ace.js"></script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
<script type="text/javascript">
	$(top.hangge());
	$(function() {
		//上传
		$('#excel').ace_file_input({
			no_file:'请选择EXCEL ...',
			btn_choose:'选择',
			btn_change:'更改',
			droppable:false,
			onchange:null,
			thumbnail:false, //| true | large
			whitelist:'xls|xls',
			blacklist:'gif|png|jpg|jpeg'
			//onchange:''
			//
		});

	});

</script>

</body>
</html>